package com.bdzl.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.bdzl.base.controller.BaseController;
import com.bdzl.common.bean.BaseResponse;
import com.bdzl.request.AddYiwai;
import com.bdzl.request.BdTj;
import com.bdzl.service.DataService;

@RestController
@RequestMapping("/v1")
public class DataController extends BaseController {

	@Resource(name = "dataService")
	private DataService dataService;

	/**
	 * 新建意外保障
	 * 
	 * @param addYiwai
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/insuranceInput/accidentProtection/{adminId}", method = RequestMethod.POST)
	public @ResponseBody BaseResponse addAdmin(@PathVariable("adminId") Integer adminId,@RequestBody AddYiwai addYiwai) throws Exception {
		BaseResponse baseResponse = dataService.newyiwai(adminId,addYiwai);

		return baseResponse;
	}

	/**
	 * 获取数据列表
	 * 
	 * @param bdTj
	 * @param pageIndex
	 * @param pageSize
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/insuranceInput/getAllInsurance", method = RequestMethod.GET)
	public @ResponseBody BaseResponse allcla( BdTj bdTj, @RequestParam("pageIndex") Integer pageIndex,
			@RequestParam("pageSize") Integer pageSize) throws Exception {
		
		BaseResponse baseResponse = dataService.allcla(bdTj, pageIndex, pageSize);

		return baseResponse;
	}

	/**
	 * 删除保单
	 * 
	 * @param insuranceId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/insuranceInput/{insuranceId}/deleteInsurance/{adminId}", method = RequestMethod.DELETE)
	public @ResponseBody BaseResponse delcla(@PathVariable("insuranceId") Integer insuranceId
			,@PathVariable("adminId") Integer adminId) throws Exception {
		BaseResponse baseResponse = dataService.delcla(insuranceId,adminId);

		return baseResponse;
	}
	
	
	
	/**
	 * 查看意外保障
	 * @param insuranceId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/insuranceInput/{insuranceId}/accidentProtection", method = RequestMethod.GET)
	public @ResponseBody BaseResponse infoaccident(@PathVariable("insuranceId") Integer insuranceId) throws Exception {
		BaseResponse baseResponse = dataService.infoaccident(insuranceId);

		return baseResponse;
	}
	
	

}
